// 引入 对应通用常量
import { questionType, difficulty, optionType } from '@/api/hmmm/constants'
// 鉴定 题目类型方法
export function filterQuestionType (val) {
  const f = questionType.find((e) => e.value === val * 1)
  return f ? f.label + '题' : '未知'
}
// 鉴定 题目类型方法
export function filterQuestionDiff (diffType) {
  const f = difficulty.find((e) => e.value === diffType * 1)
  return f ? f.label : '未知'
}
// 选项个数
export function filterOptionsNum (val) {
  const f = optionType.find((e) => e.value === val * 1)
  return f ? f.label : '未知'
}
// 格式化时间
export function filterTimeSeconds (val) {
  const h = parseInt(val / 3600)
  const minute = parseInt((val / 60) % 60)
  const second = Math.ceil(val % 60)
  const hours = h < 10 ? '0' + h : h
  const formatSecond = second > 59 ? 59 : second
  return `${hours > 0 ? `${hours}:` : ''}${minute < 10 ? '0' + minute : minute
        }:${formatSecond < 10 ? '0' + formatSecond : formatSecond}`
}
